import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyEvent;

public class Sendmessage {

     public static  void main(String[] args) throws AWTException {
         Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
         Transferable tText = null;
         Toolkit tolkit = Toolkit.getDefaultToolkit();
         String[] lists = {"迟十秒，主要是为了预留出打开", "循环五次", "己定义", "把这行取消注释", "测试测试测试"};
         Robot robot = new Robot();
         robot.delay(5000);//延迟十秒，主要是为了预留出打开窗口的时间，括号内的单位为毫秒
         int j=0;
         for (int i = 0; i <100 ; i++) {//循环五次，当然，如果爱得深，你死循环也没问题设置为100
             System.err.println(i);
             tText = new StringSelection(lists[j]); //自己定义就需要把这行注释，下行取消注释

//            tText = new StringSelection("爱你每一天");//如果爱得深，把这行取消注释，把内容更换掉你自己想说的
             clip.setContents(tText, null);
             robot.keyPress(KeyEvent.VK_CONTROL);
             robot.keyPress(KeyEvent.VK_V);
             robot.keyRelease(KeyEvent.VK_CONTROL);
             robot.keyRelease(KeyEvent.VK_V);
             //robot.keyRelease(KeyEvent.VK_CONTROL);
             robot.delay(500);
             robot.keyPress(KeyEvent.VK_ENTER);
             robot.keyRelease(KeyEvent.VK_ENTER);
             j++;
             if (j>=5){
                 j=1;
             }
         }

     }
}
